<?php
/**
 * @package panel
 * @subpackage panel.environment
 */
/**
 * Define paths, includes, requirements to load php files, functions and classes.
 * Setup environment.
 * @author Dmitry Bakaleinik (code)
 */
	/**
	 * Paths:
	 */
	define("PANEL__ID", "runcom_");
	define("PANEL__PATH",              dirname(__FILE__));
	define("PANEL__PATH__MAF",         PANEL__PATH . "/maf/");
	define("PANEL__PATH__CACHE",       PANEL__PATH . "/cache/");
	define("PANEL__PATH__SCRIPTS",     PANEL__PATH . "/scripts/");
	define("PANEL__PATH__LOGS",        PANEL__PATH . "/logs/");
	define("PANEL__PATH__WEB",         PANEL__PATH . "/web/");
	define("PANEL__PATH__MODELS",      PANEL__PATH . "/models/");
	define("PANEL__PATH__TEMPLATES",   PANEL__PATH . "/templates/");
	define("PANEL__PATH__SETTINGS",    PANEL__PATH . "/settings/");
	define("PANEL__PATH__APPLICATION", PANEL__PATH . "/application/");
	define("PANEL__PATH__RRP",         PANEL__PATH . "/rrp/");
	define("PANEL__PATH__ORM",         PANEL__PATH . "/orm/");
	define("PANEL__PATH__EXCEPTIONS",  PANEL__PATH . "/exceptions/");
	define("PANEL__PATH__INTERFACES",  PANEL__PATH . "/interfaces/");

	define("PANEL__PATH__ENVIRONMENT",   PANEL__PATH . "/environment/");

	define("PANEL__PATH__ENVIRONMENT__DB",      PANEL__PATH__ENVIRONMENT . "/db/");
	define("PANEL__PATH__ENVIRONMENT__LOGGERS", PANEL__PATH__ENVIRONMENT . "/loggers/");
	define("PANEL__PATH__ENVIRONMENT__CACHE_ENGINES", PANEL__PATH__ENVIRONMENT . "/cache/");

	/**
	 * Load MAF:
	 */
	require_once(PANEL__PATH__MAF . "/autoload.maf.php");

	/**
	 * Import required functions
	 */

	maf()->getAutoload()->importFunction("isset_or_error");
	maf()->getAutoload()->importFunction("array_get");
	maf()->getAutoload()->importFunction("generate_id");
	maf()->getAutoload()->importFunction("uri");
	maf()->getAutoload()->importFunction("dbug");
	maf()->getAutoload()->importFunction("array_diff_precise");
	maf()->getAutoload()->importFunction("str_tabshift");
	maf()->getAutoload()->importFunction("str_replace_limit");
	maf()->getAutoload()->importFunction("a");

	/**
	 * Register shortcuts
	 */
	maf()->getAutoload()->registerFunction("p",  PANEL__PATH__ENVIRONMENT, TRUE);
	maf()->getAutoload()->registerClass("panel", PANEL__PATH__ENVIRONMENT, TRUE);
	maf()->getAutoload()->importFunction("p");

	/**
	 * SETTINGS
	 */
	$_path = PANEL__PATH__SETTINGS;
	maf()->getAutoload()->registerClass("panel__settings__environment", $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__settings__db",          $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__settings__mail",        $_path, TRUE);

	/**
	 * ENVIRONMENT
	 */
	$_path = PANEL__PATH__ENVIRONMENT;
	maf()->getAutoload()->registerClass("panel__environment",          $_path, TRUE);

	/**
	 * APPLICATION
	 */

	$_path = PANEL__PATH__APPLICATION;
	maf()->getAutoload()->registerClass("panel__application",           $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__application__request",  $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__application__response", $_path, TRUE);

	/**
	 * INCLUDES
	 */

	$_path = PANEL__PATH__ENVIRONMENT;
	maf()->getAutoload()->registerClass("panel__validate", $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__template", $_path, TRUE);

	/**
	 * DB
	 */

	$_path = PANEL__PATH__ENVIRONMENT__DB;
	maf()->getAutoload()->registerClass("panel__db", 			    $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__db__pdo_statement", $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__db__select", 	    $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__db__raw_select",    $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__db__update", 	    $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__db__delete",	    $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__db__insert",	    $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__db__replace",	    $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__db__call",  	    $_path, TRUE);

	/**
	 * LOGGERS
	 */
	$_path = PANEL__PATH__ENVIRONMENT__LOGGERS;
	maf()->getAutoload()->registerClass("panel__logger__errors",  $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__logger__query",	  $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__logger__mailer",  $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__logger__console", $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__logger__access",  $_path, TRUE);

	/**
	 * EXCEPTIONS
	 */
	$_path = PANEL__PATH__EXCEPTIONS;
	maf()->getAutoload()->registerException("panel__e__exception",  				$_path, TRUE);
	maf()->getAutoload()->registerException("panel__e__unknown_processor_action",	$_path, TRUE);
	maf()->getAutoload()->registerException("panel__e__unknown_processor",  		$_path, TRUE);
	maf()->getAutoload()->registerException("panel__e__unknown_response_type",  	$_path, TRUE);
	maf()->getAutoload()->registerException("panel__e__wrong_processor_data",  		$_path, TRUE);
	maf()->getAutoload()->registerException("panel__e__unsupported_entity_given",  	$_path, TRUE);
	maf()->getAutoload()->registerException("panel__e__not_found",  				$_path, TRUE);
	maf()->getAutoload()->registerException("panel__e__trigger_exception",  		$_path, TRUE);
	maf()->getAutoload()->registerException("panel__e__access_denied",  			$_path, TRUE);
	maf()->getAutoload()->registerException("panel__e__validation",  				$_path, TRUE);
	maf()->getAutoload()->registerInterface("panel__e__i_displayable_to_user",		$_path, TRUE);

	/**
	 * RRP
	 */
	$_path = PANEL__PATH__RRP;
	maf()->getAutoload()->registerClass("panel__rrp", $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__rrp__devices_overview", $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__rrp__commands_executor", $_path, TRUE);

	/**
	 * RRP: Internal
	 */
	$_path = PANEL__PATH__RRP . "/internal/";
	maf()->getAutoload()->registerClass("panel__rrp__environment", $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__rrp__ui", $_path, TRUE);

	/**
	 * Models
	 */
	$_path = PANEL__PATH__MODELS;
	maf()->getAutoload()->registerClass("panel__model__devices",  $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__model__vendors",  $_path, TRUE);
	maf()->getAutoload()->registerClass("panel__model__commands", $_path, TRUE);

	/**
	 * Cleanup:
	 */
	unset($_path);

/* EOF */